function makeAtcgBar() {
	// atcg
	atcg = new THREE.Object3D();

	// plane
	var cubesPlaneGeometry = new THREE.PlaneGeometry(500, 500, 1, 0);
	var cubesPlaneMaterial = new THREE.MeshBasicMaterial({
		color : 0xc0c0c0,
		wireframe : false
	});
	var cubesPlane = new THREE.Mesh(cubesPlaneGeometry, cubesPlaneMaterial);
	atcg.add(cubesPlane);

	cubeGeometry = new THREE.CubeGeometry(200, 200, 50);
	textMaterial = new THREE.MeshBasicMaterial({
		color : 0x0000ff,
		wireframe : false
	});
	cubeMaterial = new THREE.MeshBasicMaterial({
		color : 0x0000ff,
		wireframe : true
	});
	positions = new Array();
	positions = new Array();
	for (var i = 0; i < 4; i++) {
		var x = (i % 2) * 240 - 120;
		var y = (1 - Math.floor(i / 2)) * 240 - 120;
		var letter = letters[i];
		if(aucg && letter == 'T'){
			letter = 'U';
		}
		makeCube(letter, atcg, x, y);
	}

	atcg.position.x = ATCG_POS_X;
	atcg.position.y = ATCG_POS_Y;
	atcg.position.z = 100;

	scene.add(atcg); // adding atcg to the scene
}

var amins;
var Tri;

function makeAminoBar() {
	/*
	amins = [ 'Glycin', 'Alanin', 'Valin', 'Leucin', 'Isoleucin',
			'Kyselina asparagova', 'Asparagin', 'Kyselina glutamova',
			'Glutamin', 'Arginin', 'Lysin', 'Histidin', 'Fenylalanin', 'Serin',
			'Threonin', 'Tyrozin', 'Tryptofan', 'Methionin', 'Cystein',
			'Prolin' ]; */
	
	amins = [ 'Glycin', 'Alanin', 'Valin', 'Leucin', 'Isoleucin',
				'Kyselina asparagova', 'Asparagin', 'Kyselina glutamova',
				'Glutamin', 'Arginin', 'Lysin', 'Histidin', 'Fenylalanin', 'Serin',
				'Threonin', 'Tyrosin', 'Tryptofan', 'Methionin', 'Cystein',
				'Prolin' ];


	Tri = new Object();
	Colors = new Object(); 
	//hydrofobni - fialova
	Tri['Leucin'] = [ 'CUU', 'CUC', 'CUA', 'CUG', 'UUA', 'UUG' ];
	Tri['Methionin'] = [ 'AUG' ];
	Tri['Valin'] = [ 'GUU', 'GUC', 'GUA', 'GUG' ];
	Tri['Alanin'] = [ 'GCU', 'GCC', 'GCA', 'GCG' ];
	Tri['Fenylalanin'] = [ 'UUU', 'UUC' ];
	Tri['Tryptofan'] = [ 'UGG' ];
	Tri['Cystein'] = [ 'UGU', 'UGC' ];
	Tri['Isoleucin'] = [ 'AUU', 'AUC', 'AUA' ];

	var c1 = 0xeA273FF;
	Colors['Leucin'] = c1; 
Colors['Methionin'] = c1; 
	Colors['Valin'] = c1; 
Colors['Alanin'] = c1; 
Colors['Fenylalanin'] = c1; 
Colors['Tryptofan'] = c1; 
Colors['Cystein'] = c1; 
Colors['Isoleucin'] = c1; 


	//polarni - zelena
	Tri['Asparagin'] = [ 'AAU', 'AAC' ];
	Tri['Glutamin'] = [ 'CAA', 'CAG' ];
	Tri['Serin'] = [ 'AGU', 'AGC', 'UCU', 'UCC', 'UCA', 'UCG' ];
	Tri['Threonin'] = [ 'ACU', 'ACC', 'ACA', 'ACG' ];
	Tri['Arginin'] = [ 'AGA', 'AGG', 'CGU', 'CGC', 'CGA', 'CGG' ];

	var c2 = 0x22EE44;
	Colors['Asparagin'] = c2;
Colors['Glutamin'] = c2;
Colors['Serin'] = c2;
Colors['Threonin'] = c2;
Colors['Arginin'] = c2;
	
	//zaporne nabity - modra 	
	Tri['Kyselina asparagova'] = [ 'GAU', 'GAC', 'GAA', 'GAG' ];
	Tri['Kyselina glutamova'] = ['GAA','GAG'];
	Tri['Tyrosin'] = [ 'UAU', 'UAC' ];

	var c3 = 0xe33A3EB;
	Colors['Kyselina asparagova'] = c3;
	Colors['Kyselina glutamova'] = c3;
	Colors['Tyrosin'] = c3;

	//kladne nabity -  
	Tri['Lysin'] = [ 'AAA', 'AAG' ];
	Tri['Histidin'] = [ 'CAU', 'CAC' ];

var c4 = 0xEB4766;
Colors['Lysin'] = c4;
Colors['Histidin'] = c4;

	//special cases - zluta 
	Tri['Glycin'] = [ 'GGU', 'GGC', 'GGA', 'GGG' ];
	Tri['Prolin'] = [ 'CCU', 'CCC', 'CCA', 'CCG' ];

	var c5 = 0xF9E454;
Colors['Glycin'] = c5;
Colors['Prolin'] = c5;
	
	
	// UAA Ochre (Stop)3 UAG Amber (Stop)3,4 UGA Opal (Stop)3,5
	
	
	
	
	

	// atcg
	atcg = new THREE.Object3D();

	// plane
	var cubesPlaneGeometry = new THREE.PlaneGeometry(500, 500, 1, 0);
	var cubesPlaneMaterial = new THREE.MeshBasicMaterial({
		color : 0xc0c0c0,
		wireframe : false
	});
	var cubesPlane = new THREE.Mesh(cubesPlaneGeometry, cubesPlaneMaterial);
	//atcg.add(cubesPlane);

	
	for (var i = 0; i < 20; i++) {
		var x = (i % 4) * 350 - 400;
		var y = (1 - Math.floor(i / 4)) * 260 + 460;// - 120;
		makeCube2(amins[i], atcg, Colors[amins[i]], x, y); // amins[i]
	}

	atcg.position.x = ATCG_POS_X-350;
	atcg.position.y = ATCG_POS_Y+60;
	atcg.position.z = -50;

	scene.add(atcg);
}

function makeDNAChain() {

	dnachain = new THREE.Object3D();

	for (var i = -5; i <= 10; i++) {
		var sphereGeom = new THREE.SphereGeometry(10, 8, 8);
		var sphereMat = new THREE.MeshBasicMaterial({
			color : Math.random() * 0xffffff,
			wireframe : false
		});

		var sphere1 = new THREE.Mesh(sphereGeom, sphereMat);
		var sphere2 = new THREE.Mesh(sphereGeom, sphereMat);

		var r = 120;
		var s = 0.6;

		sphere1.position.x = Math.cos(i * s) * r;
		sphere1.position.y = i * 30;
		sphere1.position.z = Math.sin(i * s) * r;
		sphere2.position.x = Math.cos(i * s + Math.PI) * r;
		sphere2.position.y = i * 30;
		sphere2.position.z = Math.sin(i * s + Math.PI) * r;

		// spheres[i + 30] = sphere1;

		dnachain.add(sphere1);
		dnachain.add(sphere2);

		dnachain.position.x = CHAIN_POS_X;
		dnachain.position.y = CHAIN_POS_Y;
	}

	scene.add(dnachain);
}

function makeDNAPas() {

	pas = new THREE.Object3D();

	// plane
	var planeGeometry = new THREE.PlaneGeometry(220, 1000, 1, 0);
	var planeMaterial = new THREE.MeshBasicMaterial({
		color : 0xa0a0a0,
		wireframe : true
	});

	var plane = new THREE.Mesh(planeGeometry, planeMaterial);

	//pas.add(plane);

	pas.position.x = PAS_POS_X;
	pas.position.y = PAS_POS_Y;

	scene.add(pas);
}

// var randomLetters = ['A','A','A','A','A'];

function makeDNAPas2() {

	pas2 = new THREE.Object3D();

	// plane
	var planeGeometry = new THREE.PlaneGeometry(220, 1000, 1, 0);
	var planeMaterial = new THREE.MeshBasicMaterial({
		color : 0xa0a0a0,
		wireframe : true
	});

	var plane = new THREE.Mesh(planeGeometry, planeMaterial);

	//pas2.add(plane);

	pas2.position.x = PAS2_POS_X;
	pas2.position.y = PAS2_POS_Y;

	for (var i = 0; i < ncubes; i++) {
		var r = Math.floor(Math.random() * 4);
		var letter = letters[r];
		makeCube(letter, pas2, 0, i * 200 + 1000);
	}

	scene.add(pas2);
}

function makeTriPas(){
	pas2 = new THREE.Object3D();
	
	// plane
	var planeGeometry = new THREE.PlaneGeometry(220, 1000, 1, 0);
	var planeMaterial = new THREE.MeshBasicMaterial({
		color : 0xa0a0a0,
		wireframe : true
	});

	var plane = new THREE.Mesh(planeGeometry, planeMaterial);

	pas2.add(plane);

	pas2.position.x = PAS2_POS_X + 150;
	pas2.position.y = PAS2_POS_Y;

	
	for (var i = 0; i < ncubes; i++) {
		var triplet = randomTriplet();
		var color = 0xaaaaaa;
		makeCube2(triplet , pas2,color,  0, i * 220 + 1000); // i * 200 + 1000
	}  
	
	scene.add(pas2);
}

function randomTriplet(){
	//SELECT RANDOM TRIPLET
	var rand = Math.floor(Math.random() * amins.length); 
	var randAmino = amins[rand];
	var triplets = Tri[randAmino];
	var rand2 = Math.floor(Math.random() * triplets.length);
	return randTriplet = triplets[rand2];
}

function makeCube(letter, parent, x, y) {
	cubeGeometry = new THREE.CubeGeometry(320, 200, 50);
	textMaterial = new THREE.MeshBasicMaterial({
		color : 0x0000ff,
		wireframe : false
	});
	cubeMaterial = new THREE.MeshBasicMaterial({
		color : 0x0000ff,
		wireframe : false,
		transparent: true,
		opacity: 0.2
	});

	var textGeo = new THREE.TextGeometry(letter, {
		size : 50,
		height : 5,
		face : "helvetiker"
	});
	textGeo.text = letter;
	textGeo.computeBoundingBox();

	var textMesh = new THREE.Mesh(textGeo, textMaterial.clone());
	textMesh.position.x = -130;
	textMesh.position.y = -40;

	// textMesh.geometry.text
	// cubeMesh
	var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());

	// node for cube & mesh
	var node = new THREE.Object3D();
	node.add(textMesh);
	node.add(cubeMesh);
	node.position.x = x;
	node.position.y = y;

	parent.add(node);

	return node;
}

function makeCube2(letter, parent, color, x, y) {

	var text1 = letter;
	var text2 = "";
	for (var i = 0; i < letter.length; i++) {
		var l = letter[i];
		if (l == ' ') {
			text1 = letter.substring(0, i);
			text2 = letter.substring(i + 1, letter.length);
		}
	}

	cubeGeometry = new THREE.CubeGeometry(320, 200, 20);
	textMaterial = new THREE.MeshBasicMaterial({
		color : 0x555555, 
		transporent:true,
		opacity:0.1,//0x0000ff,
		wireframe : false
	});
	
	cubeMaterial = new THREE.MeshBasicMaterial({
		color : color,
		//opacity: 0.3,
		wireframe : false
	});

	var cubeMaterial2 = new THREE.MeshBasicMaterial({
		color : 0x555555,
		//opacity: 0.3,
		wireframe : true
	});

	var textGeo1 = new THREE.TextGeometry(text1, {
		size : 40,
		height : 2,
		face : "helvetiker"
	});
	textGeo1.text = text1;
	textGeo1.computeBoundingBox();

	var textMesh1 = new THREE.Mesh(textGeo1, textMaterial.clone());
	textMesh1.position.x = -120;
	textMesh1.position.y = 0;
	textMesh1.position.z = 10;

	// textMesh.geometry.text
	// cubeMesh
	var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());
var cubeMesh2 = new THREE.Mesh(cubeGeometry, cubeMaterial2.clone());
	cubeMesh2.position.x += 5;
	cubeMesh2.position.z +=10;

	// node for cube & mesh
	var node = new THREE.Object3D();
	node.add(textMesh1);
	node.add(cubeMesh);
	node.add(cubeMesh2);

	if (text2 != "") {
		var textGeo2 = new THREE.TextGeometry(text2, {
			size : 30,
			height : 3,
			face : "helvetiker"
		});
		textGeo2.text = text2;
		textGeo2.computeBoundingBox();

		var textMesh2 = new THREE.Mesh(textGeo2, textMaterial.clone());
		textMesh2.position.x = -95;
		textMesh2.position.y = -40;
	   textMesh2.position.z = 10;

		node.add(textMesh2);
	}

	node.position.x = x;
	node.position.y = y;
	parent.add(node);
	node.color = color;
	node.text = letter;
	return node;
}

function makeFinalMessage() {

	var message = new THREE.Object3D();

	// plane
	var planeGeometry = new THREE.PlaneGeometry(1200, 500, 1, 0);
	var planeMaterial = new THREE.MeshBasicMaterial({
		color : 0xc0c0c0,
		wireframe : false
	});
	var plane = new THREE.Mesh(planeGeometry, planeMaterial);
	message.add(plane);

	var textMaterial = new THREE.MeshBasicMaterial({
		color : 0x0000ff,
		wireframe : false
	});

	var textGeo = new THREE.TextGeometry('Good job!', {
		size : 100,
		height : 20,
		face : "helvetiker"
	});

	textGeo.computeBoundingBox();

	var textMesh = new THREE.Mesh(textGeo, textMaterial.clone());
	textMesh.position.x = -300;
	message.add(textMesh);

	message.position.z = 300;
	scene.add(message); // adding atcg to the scene

	dnachain.position.z = 400;

}

function createHydroConnection(parent, x, y, n) {
	cubeGeometry = new THREE.CubeGeometry(50, 20, 20);

	cubeMaterial = new THREE.MeshBasicMaterial({
		color : Math.random() * 0xffffff,
	});

	var node = new THREE.Object3D();
	node.position.x = x + 100;
	node.position.y = y;
	node.position.z = 50;

	for (var i = 0; i < n; i++) {
		var cubeMesh = new THREE.Mesh(cubeGeometry, cubeMaterial.clone());
		cubeMesh.position.y = i * 30 - 30;
		node.add(cubeMesh);
		parent.add(node);
	}

	return node;
}
